The Building Blocks of a Central Application
Table of Contents
Notices
The application and the pod each have a sayHi() method which sends a notice—in this case a "hi" message. Below is the sayHi() function the pod uses:
// Function that sends a notice from the pod
function sayHi() {
// Creates a new notice object
notice = new Object();
notice.name = "The pod said hi!";
notice.description = "This is an example of a Central notice.";
notice.alert = true;
notice.timeout = 30;
notice.navigate = true;
notice.engageString = "React";
this.gConsole.addNotice(notice);
}
Here's what some of the properties of the notice in the sayHi()function
do. The timeout property makes the notices disappear after 30
seconds so that they don't clutter your screen. To have another part of the
application react to a notice, you have to set up an engage link. The engageString property
specifies which text to display for the engage link inside the notice. In this
case, a link titled "React" will send information back to the application.
To handle the user engagement, you have to write an onNoticeEvent function
in either the application, the agent, or the pod, or in all of them, depending
on which part of your application you want to handle the notice event. I included
it in the application itself, and it looks like this:
onNoticeEvent = function(event, noticeData) {
if (event.type == "engage") {
star.gotoAndPlay("dance");
}
}
Very simple. It plays a little animation in the main application window, indicating that the user clicked the engage link.